package com.stars.home.vmodel

import android.app.Application
import android.os.Bundle
import android.view.View
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.stars.home.model.FindApplyBean
import com.stars.home.model.User
import com.stars.home.utils.net.NetEngine
import com.trailer.base.base.BRepository
import com.trailer.base.base.BViewModel
import kotlinx.coroutines.launch


class RealNameVModel(application: Application) : BViewModel<BRepository>(application) {

    var card=MutableLiveData<String>()
    var realName=MutableLiveData<String>()



    var imgOne=MutableLiveData<String>()
    var imgTwo=MutableLiveData<String>()
    var imgThree=MutableLiveData<String>()
    var imgFour=MutableLiveData<String>()
    var user=MutableLiveData<User>()

    var bean=MutableLiveData<FindApplyBean>()




    fun toContact(){
        toast("敬请期待")
    }


    fun isShowOne(type:Int?,status:Int?):Int{
        if(type==1&&status==2){
            return View.VISIBLE
        }
        return View.GONE
    }

    fun isShowTwo(type:Int?,status:Int?):Int{
        if(type==0&&status==1){
            return View.VISIBLE
        }
        return View.GONE
    }




    fun isShow(type:Int?,status:Int?):Int{
        if(type==0&&status==-1){
            return View.VISIBLE
        }
        return View.GONE
    }


    fun getUserInfo(){
        viewModelScope.launch {
            var it=repository().lreq { NetEngine.service.getUser() }
            if(it.ok()) {
                user.value = it.data
            }
        }
    }

    fun getCoopStatus(){
        viewModelScope.launch{

            var it=repository().lreq { NetEngine.service.findApply() }

            if(it.ok()){
                bean.value=it.data
                realName.value=it.data?.realName
                card.value=it.data?.idCard
                imgOne.value=it.data?.idCardJust
                imgTwo.value=it.data?.idCardBack
                imgThree.value=it.data?.qualifications
                imgFour.value=it.data?.occupationMirror

            }
        }
    }



}



